package com.alpha.processor.creators.info_model;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.VariableElement;

public class ViewInfoModel {

    private Element viewBinderElement;
    private Element clickAspectElement;

    private Map<Integer,String> viewIdMap;

    private final Set<String> viewBinderViewSet = new HashSet<>();
    private final Map<String,Element> clickMethodElementMap = new HashMap<>();

    public void updateClickAspectElement(Element clickAspectElement){
        this.clickAspectElement = clickAspectElement;
    }

    public void updateViewBinderElement(Element viewBinderElement,Element binderClassElement) {
        this.viewBinderElement = viewBinderElement;
        for(Element element:binderClassElement.getEnclosedElements()) {
            if (element.getKind() == ElementKind.FIELD){
                VariableElement fieldElement = (VariableElement) element;
                String name = fieldElement.getSimpleName().toString();
                viewBinderViewSet.add(name);
            }
        }
    }

    public void updateViewIdMap(Map<Integer,String> viewIdMap){
        this.viewIdMap = viewIdMap;
    }

    public void putClickMethodElement(String methodName,Element element){
        clickMethodElementMap.put(methodName,element);
    }

    public Element getViewBinderElement() {
        return viewBinderElement;
    }

    public Element getClickAspectElement() {
        return clickAspectElement;
    }

    public Map<String, Element> getClickMethodElementMap() {
        return clickMethodElementMap;
    }

    public Map<Integer, String> getViewIdMap() {
        return viewIdMap;
    }

    public Set<String> getViewBinderViewSet() {
        return viewBinderViewSet;
    }
}
